function $POST_JSON(url, postData, successCallback, errorCallback) {
    var type = type || "POST";
    $.ajax({
        url:url,
        data:JSON.stringify(postData),
        dataType:'json',
        xhrFields: {
            withCredentials: true
        },
        type:type,
        contentType:"application/json",
        beforeSend:function () {
        },
        success:function (res) {
            if(res.success){
                if(successCallback){
                    successCallback(res.data);
                }
            }else{
                if(errorCallback){
                    errorCallback(res);
                }
            }
        },
        fail:function () {
            if(errorCallback){
                errorCallback();
            }
        },
        complete:function () {
        }
    })
}

function $AJAX(url, postData, successCallback, errorCallback,type){
    var type = type || "POST";
    $.ajax({
        url:url,
        data:JSON.stringify(postData),
        dataType:'json',
        xhrFields: {
            withCredentials: true
        },
        type:type,
        contentType:"application/json",
        beforeSend:function () {
        },
        success:function (res) {
            if(res.success){
                if(successCallback){
                    successCallback(res.data);
                }
            }else{
                if(errorCallback){
                    errorCallback(res);
                }
            }
        },
        fail:function () {
            if(errorCallback){
                errorCallback();
            }
        },
        complete:function () {
        }
    })
}

function $POST(url,postData, successCallback, errorCallback) {
    var type = type || "POST";
    $.ajax({
        url:url,
        data:postData,
        xhrFields: {
            withCredentials: true
        },
        type:type,
        beforeSend:function () {
        },
        success:function (res) {
            if(res.success){
                if(successCallback){
                    successCallback(res.data);
                }
            }else{
                if(errorCallback){
                    errorCallback(res);
                }
            }
        },
        fail:function () {
            if(errorCallback){
                errorCallback();
            }
        },
        complete:function () {
        }
    })
}

function $GET(url, successCallback, errorCallback) {
    var type = type || "GET";
    $.ajax({
        url:url,
        xhrFields: {
            withCredentials: true
        },
        type:type,
        beforeSend:function () {
        },
        success:function (res) {
            if(res.success){
                if(successCallback){
                    successCallback(res.data);
                }
            }else{
                if(errorCallback){
                    errorCallback(res);
                }
            }
        },
        fail:function () {
            if(errorCallback){
                errorCallback();
            }
        },
        complete:function () {
        }
    })
}

/**
 * Form转Json
 * @param $form
 */
function getFormData($form) {
    var unindexed_array = $form.serializeArray();
    var indexed_array = {};
    $.map(unindexed_array, function (n, i) {
        indexed_array[n['name']] = n['value'].trim();
    });
    return indexed_array;
}

/**
 * 保留小数2位的00
 * @param number
 * @returns {string|*}
 */
function keep2smallNumber(number) {
    if (number * 100 % 100 == 0) {
        return number + ".00"
    } else {
        return number
    }
}